package com.apes.bi.model;

import com.apes.framework.api.SpringManager;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CanvasContent.CONST_TABLE_NAME)

public class CanvasContent extends BaseModel {
    public static final String CONST_TABLE_NAME = "bi_canvas_content";

    @Id
    @ApesGenerator(code = CONST_TABLE_NAME, name = "报表画布内容")
    @Column(name = "id", length = 60)
    private String id;

    @Comment("小程序")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "applet_id", referencedColumnName = "id")
    private Applet applet;


    @Comment("所属列")
    @Column(name = "belong_column", length = 20)
    private int belongColumn;

    @Comment("所属顺序")
    @Column(name = "belong_order", length = 20)
    private int belongOrder;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "canvas_id", referencedColumnName = "id", nullable = false)
    @Comment("画布")
    private Canvas canvas;

    @Lob
    @Comment("个人数据")
    @Column(name = "custom_metadata ", columnDefinition = "CLOB")
    private String customMetadata;


}
